#include <dbg.h>

#include <cassert>

using namespace std;

class Solution {
public:
    int findMin(vector<int>& nums) {
        int left = -1;
        int right = nums.size() - 1;
        while (left + 1 < right) {
            int mid = left + (right - left) / 2;
            if (nums[mid] > nums[right]) {
                left = mid;
            } else {
                right = mid;
            }
        }
        return nums[right];
    }
};

int main() {
    Solution s;

    vector<int> nums1{3, 4, 5, 1, 2};
    vector<int> nums2{4, 5, 6, 7, 0, 1, 2};
    vector<int> nums3{11, 13, 15, 17};
    vector<int> nums4{3, 1, 2};

    assert(s.findMin(nums1) == 1);
    assert(s.findMin(nums2) == 0);
    assert(s.findMin(nums3) == 11);
    assert(s.findMin(nums4) == 1);

    return 0;
}